package cn.xi.dao;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface ReportDao {

    @Select("select  COUNT(*) from t_member where regTime =#{s}")
    Integer selectTimeNumber(String s);

    @Select("select  COUNT(*) from t_member ")
    Integer totalMember();

    @Select("select COUNT(*) from `t_member` where regTime<=#{simpleDateFormat} and regTime >=#{format}")
    Integer thisWeekNewMember(@Param("format") String format, @Param("simpleDateFormat") String simpleDateFormat);

    @Select("select  COUNT(*) from t_order where orderDate =#{s}")
    Integer todayOrderNumber(String simpleDateFormat);

    @Select("select  COUNT(*) from t_order where orderDate =#{simpleDateFormat} and orderStatus=#{string}")
    Integer todayVisitsNumber(@Param("simpleDateFormat") String simpleDateFormat,@Param("string")String string);


    @Select("select COUNT(*) from `t_order` where orderDate<=#{format} and orderDate >=#{simpleDateFormat}")
    Integer thisWeekOrderNumber(@Param("format") String format, @Param("simpleDateFormat")String simpleDateFormat);

    @Select("select COUNT(*) from `t_order` where orderDate<=#{format} and orderDate >=#{simpleDateFormat} and orderStatus=#{orderstatusYes}")
    Integer thisWeekVisitsNumber(@Param("format") String format, @Param("simpleDateFormat")String simpleDateFormat,@Param("orderstatusYes") String orderstatusYes);
@Select("select s.name ,COUNT(o.setmeal_id) setmeal_count,COUNT(o.setmeal_id)/(select COUNT(*) from t_order)  proportion from  t_setmeal s,t_order o where o.setmeal_id=s.id group by o.setmeal_id order by setmeal_count  desc limit 0,4")
    List<Map> hotSetmeal();
}
